<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Element对象</title>
</head>
<body>
<a >百度一下</a>
<input id ="btn_set" type="button" value="设置属性">
<input id ="btn_remove" type="button" value="删除属性">
<script>

    /*
    * 方法：removeAttribute()删除属性,setAttribute()设置属性
    *
    * */
    var a = document.getElementsByTagName("a")[0];
    var btn_set = document.getElementById("btn_set");
    btn_set.onclick=function () {
        a.setAttribute("href","https://www.baidu.com");
    }
    var btn_remove = document.getElementById("btn_remove");
    btn_remove.onclick=function () {
        a.removeAttribute("href");
    }
</script>
</body>
</html>